const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('sunnyCode', {
    id: {
      type: DataTypes.BIGINT,
      allowNull: false,
      primaryKey: true,
      comment: "主键"
    },
    datasourceId: {
      type: DataTypes.BIGINT,
      allowNull: true,
      comment: "数据源主键",
      field: 'datasource_id'
    },
    serviceName: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: "服务名称",
      field: 'service_name'
    },
    codeName: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: "模块名称",
      field: 'code_name'
    },
    tableName: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: "表名",
      field: 'table_name'
    },
    tablePrefix: {
      type: DataTypes.STRING(64),
      allowNull: true,
      comment: "表前缀",
      field: 'table_prefix'
    },
    pkName: {
      type: DataTypes.STRING(32),
      allowNull: true,
      comment: "主键名",
      field: 'pk_name'
    },
    packageName: {
      type: DataTypes.STRING(500),
      allowNull: true,
      comment: "后端包名",
      field: 'package_name'
    },
    baseMode: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "基础业务模式",
      field: 'base_mode'
    },
    wrapMode: {
      type: DataTypes.INTEGER,
      allowNull: true,
      comment: "包装器模式",
      field: 'wrap_mode'
    },
    apiPath: {
      type: DataTypes.STRING(2000),
      allowNull: true,
      comment: "后端路径",
      field: 'api_path'
    },
    webPath: {
      type: DataTypes.STRING(2000),
      allowNull: true,
      comment: "前端路径",
      field: 'web_path'
    },
    isDeleted: {
      type: DataTypes.INTEGER,
      allowNull: true,
      defaultValue: 0,
      comment: "是否已删除",
      field: 'is_deleted'
    }
  }, {
    sequelize,
    tableName: 'sunny_code',
    timestamps: true,
    createdAt: 'createTime',
    updatedAt: 'updateTime',
    deletedAt: 'deleteTime',
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "id" },
        ]
      },
    ]
  });
};
